package com.heima.user.controller;

import com.heima.model.admin.pojos.ApUserRealname;
import com.heima.model.common.dtos.ApUserRealnameDto;
import com.heima.model.common.dtos.PageSensitive;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.user.service.ApUserRealnameService;
import com.heima.user.service.ApUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/api/v1/auth")
@RestController
public class UserController {
    
    @Autowired
    private ApUserRealnameService apUserRealnameService;

    @PostMapping("/list")
    public ResponseResult list(@RequestBody ApUserRealnameDto dto){
        ResponseResult rlist = apUserRealnameService.rlist(dto);
        return rlist;
    }
    @PostMapping("/authPass")
    public ResponseResult auth(@RequestBody ApUserRealname apUserRealname){
        ApUserRealname byId = apUserRealnameService.getById(apUserRealname.getId());
        if (byId.getStatus()==9){
            return ResponseResult.okResult("已经是通过状态");
        }
        ApUserRealname apUserRealname1 = new ApUserRealname();
        apUserRealname1.setId(apUserRealname.getId());
        apUserRealname1.setStatus((short) 9);
        apUserRealnameService.updateById(apUserRealname);
        return ResponseResult.okResult("ok");
    }
    @PostMapping("/authFail")
    public ResponseResult fail(@RequestBody ApUserRealname apUserRealname){
        ApUserRealname realname = new ApUserRealname();
        realname.setId(apUserRealname.getId());
        realname.setStatus((short)2);
        apUserRealnameService.updateById(realname);
        return ResponseResult.okResult("ok");
    }

}
